<?php

require_once dirname(__FILE__) . '/Sides.php';
require_once dirname(__FILE__) . '/Side.php';

class Dice_Die
{
    private $_sides = null;

    public function __construct($sides)
    {
        $this->setSides($sides);
    }

    public function roll()
    {
        $sides = $this->getSides();
        $num_sides = $sides->getNumSides();

        $side_index = rand(0, $num_sides - 1);

        $side = $sides->getSideAtIndex($side_index);

        $side_value = $side->getValue();

        return $side_value;
    }

    public function getSides()
    {
        return $this->_sides;
    }

    public function setSides($sides)
    {
        $this->_sides = $sides;
    }
}
